<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        console.log(name);
        var name='kevin'

        //注意：
        // 1.当声明变量时不加任何关键字 ，则代表声明为window下的全局变量
        workage=10;
        console.log(workage)
        function foo(){
            //当foo被调用时，globalvar会成为全局变量，因为没有声明，等于window.globalvar
            globalvar='hhelo' //相等于 window.globalvar='hhelo'
            globalfun=function(){console.log('hi')}
            return function(){}
        }
        const foo1=foo();
        console.log(globalvar) // undefined
    </script>
</body>
</html>